package logic

import (
	"activity_srv/activity"
	"activity_srv/internal/dao"
	"activity_srv/internal/svc"
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
)

type SetDistributionUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSetDistributionUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetDistributionUserLogic {
	return &SetDistributionUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 设置分销用户
func (l *SetDistributionUserLogic) SetDistributionUser(in *activity.SetDistributionUserRequest) (*activity.SetDistributionUserResponse, error) {
	//业务逻辑
	user, err := dao.SetDistributionUser(in)
	if err != nil {
		pkg.Error("设置分销用户失败", zap.Error(err))
		return nil, err
	}
	pkg.Info("设置分销用户成功", zap.Int64("id", user))

	return &activity.SetDistributionUserResponse{
		Id: user,
	}, nil
}
